package com.iterator.iterator;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * 遍历信息工程学院中的 系 的迭代器
 */
public class InfoCollegeIterator implements Iterator {

    private List<Department> departments = new ArrayList<>();
    private int position =0 ;

    //构造
    public InfoCollegeIterator(List<Department> departments) {
        this.departments = departments;
    }

    @Override
    public boolean hasNext() {
        if (position >= departments.size() || departments.get(position) == null){
            return false ;
        }
        return true;
    }

    @Override
    public Object next() {
        Department department = departments.get(position);
        position += 1 ;
        return department;
    }

    @Override
    public void remove() {

    }
}
